/*
 * just 8 possibilities at all, for example:
 * buttons: 1->3->4->2->4, equals to: 1->3->2
 * and, 1->3->4 equals to 1->4->3 (order doesn't matter)
 *
 *  最终状态            灯灭的位置                     摁按钮次数
	0000000000000000……  all                     1or2
	0011100011100010……                          2or3   
	0101010101010101……  2k+1                 1or2    
	0110110110110110……  3k+1                 1or4
	1001001001001001……  3k&&3k-1           2or3
	1010101010101010……  2k                     1or2
	1100011100011100……                          2or3
	1111111111111111……  none                  3
    当摁按钮次数c>=5时，奇数可以转化成1或3，偶数可以转化成2或4.
	参考上面的摁按钮次数，可知c>=3时8种状态都可以达到。
 */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100
#define ALL 8
/* all possibilities */
const char str[ALL][N+1]={ 
	"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
	"0011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011",
	"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",
	"0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110",
    "1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001",
	"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",
    "1100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100",
	"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
};
int output[ALL]; /* for each possibility */
int out[2][ALL] = {
	{1, 0, 1, 1, 0, 1, 0, 0}, 
	{1, 1, 1, 0, 1, 1, 1, 1},
};
int on[2], off[2];
int n, c;

void
consistent()
{
	int i, j;
	for(i=0; i<2; i++) {
		for(j=0; j<ALL; j++) {
			if((on[i]-1>=0 && str[j][on[i]-1]=='0') || (off[i]-1>=0 && str[j][off[i]-1]=='1')) 
				output[j] = 0;
		}
	}
}

int 
main(int argc, char **argv)
{
	int i, temp;
	memset(on, 0, sizeof(int)*2);
	memset(off, 0, sizeof(int)*2);
	scanf("%d", &n);
	scanf("%d", &c);
	i = 0;
	while(scanf("%d", &temp) && temp!=-1)
		on[i++] = temp;
	i = 0;
	while(scanf("%d", &temp) && temp!=-1)
		off[i++] = temp;
	
	for(i=0; i<ALL; i++)
		output[i] = 1;
	if(c<=2)
		memcpy(output, out[c-1], sizeof(int)*ALL);
	consistent();

	for(i=0; i<ALL; i++) {
		if(output[i] == 1)
			printf("%.*s\n", n, str[i]);
	}
}
